<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: random_products.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$module_smarty = new Smarty();
$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');

$random_products = $db->db_query_limit("SELECT
												*
											FROM
												".TABLE_PRODUCTS." p,
												".TABLE_PRODUCTS_DESCRIPTION." pd,
												".TABLE_PRODUCTS_TO_CATEGORIES." p2c,
												".TABLE_CATEGORIES." c
											WHERE
												c.categories_status = '1'
											AND
												p.products_id = p2c.products_id
											AND
												p.products_id = pd.products_id
											AND
												p2c.categories_id = c.categories_id
												".$product->groupCheck().$product->fsk18()."
											AND
												p.products_status = '1'
											AND
												pd.language_id = '".(int) $_SESSION['languages_id']."'
											ORDER BY 
												RAND()", MAX_RANDOM_PRODUCTS, true);

$module_content = array ();
$list_data = get_list_data('random_products');
$row = 0;
while(!$random_products->EOF) { $row++;
	$module_content[] = $product->buildDataArray($random_products->fields, 'thumbnail', $list_data, $row);
	$random_products->MoveNext();
}

if(sizeof($module_content) >= 1) {
	$module_smarty->assign('language', $_SESSION['language']);
	$module_smarty->assign('module_content', $module_content);
	$module_smarty->assign('TITLE', RANDOM_PRODUCTS);
	if($list_data['col']>1)
		$module_smarty->assign('CLASS_NAME', 'grid');
	else
		$module_smarty->assign('CLASS_NAME', 'list');
	$module_smarty->assign('LIST_NAME', 'random_products');

	if (!CacheCheck()) {
		$module_smarty->caching = false;
		$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/'.$list_data['list_file'].'.html');
	} else {
		$module_smarty->caching = true;
		$module_smarty->cache_lifetime = CACHE_LIFETIME;
		$module_smarty->cache_modified_check = CACHE_CHECK;
		$cache_id = $_SESSION['language'].'_'.$_SESSION['customers_status']['customers_status_name'].'_'.$_SESSION['currency'];
		$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/'.$list_data['list_file'].'.html', $cache_id);
	}
	$default_smarty->assign('MODULE_random_products', $module);
}